home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / dynPaintPanel.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  8.8 KB  |  273 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. // Create a scripted panel for the DynPaint editor
  19. //
  20.  
  21. global string $dpToolbar;
  22. global int $gDynPaintEdCreatedFirstTime = 0;
  23.  
  24. global proc buildDynPaintContextHelpItems(string $nameRoot, string $menuParent)
  25. //
  26. //  Description:
  27. //        Build context sensitive menu items
  28. //        
  29. //  Input Arguments:
  30. //        $nameRoot - name to use as the root of all item names
  31. //        $menuParent - the name of the parent of this menu
  32. //
  33. //  Return Value:
  34. //      None
  35. //
  36. {
  37.     menuItem -label "Help on Paint Effects..."
  38.         -enableCommandRepeat false
  39.         -command "showHelp PaintEffects";
  40.     menuItem -label "Help on Paint Effects Panel..."
  41.         -enableCommandRepeat false
  42.         -command "showHelp PaintEffectsPanel";
  43. }
  44.  
  45. global proc dynPaintPanel( string $panelName )
  46. {
  47.     // Do nothing, but required to be called to load the other methods. APP 16dec98
  48.  
  49. global proc setDynPaintToolbar( int $state )
  50. {
  51.     global string $dpToolbar;
  52.  
  53.     formLayout
  54.     -edit
  55.     -manage        $state
  56.     $dpToolbar;
  57. }
  58.  
  59. global proc dynPaintCreateCallback(string $panelName) {
  60.  //
  61.  //  Description:
  62.  //      Create any editors unparented here and do
  63.  //      any other initialization required.
  64.     dynPaintEditor -unParent  ($panelName+"Ed");
  65.  
  66. }
  67.  
  68.  
  69. global proc dynPaintInitCallback(string $panelName)
  70. //
  71. //  Description:
  72. //        Called on file -new/open.
  73. //
  74. //        Take this opportunity to update the state of the panel UI etc.
  75. //
  76. {
  77.     //    Update the state of the horizontal and vertical wrap toggle buttons
  78.     //    on the tool bar.  The easiest way to do this is to just set the 
  79.     //    attribute to its current value.  This will cause all UI tied to this
  80.     //    attribute via the 'connectControl' command to be updated to the 
  81.     //    appropriate value (ie. if the Stroke Globals window and/or Channel
  82.     //    Box is also visible then the appropriate controls will be updated
  83.     //    accordingly.
  84.     //
  85.     //    Bug #115364 - bwk 14jul99.
  86.     //
  87.     setAttr "strokeGlobals.wrapH" `getAttr "strokeGlobals.wrapH"`;
  88.     setAttr "strokeGlobals.wrapV" `getAttr "strokeGlobals.wrapV"`;
  89.     // Do the rest of them too. Bug 119534 - APP 09mar00
  90.     setAttr "strokeGlobals.canvasScale"      `getAttr "strokeGlobals.canvasScale"`;
  91.     setAttr "strokeGlobals.useCanvasLight"   `getAttr "strokeGlobals.useCanvasLight"`;
  92.     setAttr "strokeGlobals.forceTubeDirAlongPath"   `getAttr "strokeGlobals.forceTubeDirAlongPath"`;
  93.     setAttr "strokeGlobals.lightDirectionX" `getAttr "strokeGlobals.lightDirectionX"`;
  94.     setAttr "strokeGlobals.lightDirectionY" `getAttr "strokeGlobals.lightDirectionY"`;
  95.     setAttr "strokeGlobals.lightDirectionZ" `getAttr "strokeGlobals.lightDirectionZ"`;
  96.     setAttr "strokeGlobals.sceneScale"       `getAttr "strokeGlobals.sceneScale"`;
  97.     setAttr "strokeGlobals.sceneWrapH"       `getAttr "strokeGlobals.sceneWrapH"`;
  98.     setAttr "strokeGlobals.sceneWrapV"       `getAttr "strokeGlobals.sceneWrapV"`;
  99.     setAttr "strokeGlobals.forceRealLights"  `getAttr "strokeGlobals.forceRealLights"`;
  100.     setAttr "strokeGlobals.forceDepth"       `getAttr "strokeGlobals.forceDepth"`;
  101. }
  102.  
  103.  
  104. global proc dynPaintAddCallback(string $panelName) {
  105.  //
  106.  //  Description:  Create UI and parent any editors.
  107.  //
  108.     global int $gDynPaintEdCreatedFirstTime;
  109.  
  110.     global string $gDynPaintEditorName;
  111.     global string $dpToolbar;
  112.  
  113.     string $mbarName = `panel -q -control $panelName`;
  114.     string $editorName = ($panelName+"Ed");
  115.     $gDynPaintEditorName = $editorName;
  116.     int    $menusOkayInPanels = `optionVar -q allowMenusInPanels`;
  117.     // This is the name of the brush shelf
  118.     global string $gBrushShelfTopLevel = "";
  119.  
  120.      if (`menuBarLayout -exists $mbarName`) {
  121.          dynPaintMenus($editorName, $mbarName);
  122.         menuBarLayout -e -mbv $menusOkayInPanels $mbarName;
  123.     }
  124.  
  125.     //    Add support for the Context Sensitive Help Menu.
  126.     //
  127.     addContextHelpProc  $panelName "buildDynPaintContextHelpItems";
  128.  
  129.     // Make the selection context
  130.     global string $gSelect;  // Selection super context
  131.  
  132.     global string $gDynSelectTool;
  133.     
  134.     // For Complete and above only
  135.     
  136.     if (`isTrue "MayaCreatorExists"` && 
  137.         (`licenseCheck -m "edit" -typ "particlePaint"`)) {
  138.          $gDynSelectTool = `dynSelectCtx -enb 0`;  // Disabled by default
  139.         superCtx -edit -attach $gDynSelectTool $gSelect;      
  140.     }
  141.     
  142.     // Make the paint context
  143.  
  144.     // global string $gDynPaintTool;
  145.     // $gDynPaintTool = `dynPaintCtx`;
  146.  
  147.     // Make the layouts
  148.     
  149.     string $viewForm = `formLayout`;
  150.         string $toolbarForm = `formLayout "dynToolbar"`;
  151.             string $toolbar = dynPaintToolbar( $editorName );
  152.             formLayout
  153.                 -edit
  154.                 -attachForm    $toolbar    "left"        0
  155.                 -attachForm    $toolbar    "right"        0
  156.                 -attachForm    $toolbar    "top"        0
  157.                 -attachForm    $toolbar    "bottom"    0
  158.                 $toolbarForm;
  159.     
  160.     //    dynPaintEditor -e -parent $editorForm $toolbarForm;
  161.     
  162.         setParent $viewForm;    
  163.         string $editorForm = `formLayout`;
  164.             dynPaintEditor -e -parent $editorForm  $editorName;
  165.             formLayout -e 
  166.                 -attachForm $editorName "top" 0
  167.                 -attachForm $editorName "left" 0 
  168.                 -attachForm $editorName "right" 0 
  169.                 -attachForm $editorName "bottom" 0 
  170.                 $editorForm;
  171.         setParent ..;
  172.     
  173.         formLayout -e 
  174.             -attachForm        $toolbarForm        "left"        0
  175.             -attachForm        $toolbarForm        "right"        0
  176.             -attachForm        $toolbarForm        "top"        0
  177.             -attachNone        $toolbarForm        "bottom"
  178.         
  179.             -attachControl $editorForm "top" 0    $toolbarForm
  180.             -attachForm $editorForm "left" 0 
  181.             -attachForm $editorForm "right" 0 
  182.             -attachForm $editorForm "bottom" 0 
  183.             $viewForm;
  184.     
  185.     setParent ..;
  186.  
  187.     // Set the default clear colour
  188.     if (`optionVar -exists dynPaintPanelClearColour` == 0) {
  189.         // Create the option var.
  190.         optionVar -floatValueAppend dynPaintPanelClearColour 0.0;
  191.         optionVar -floatValueAppend dynPaintPanelClearColour 0.0;
  192.         optionVar -floatValueAppend dynPaintPanelClearColour 0.0;
  193.     }
  194.  
  195.     // set the script job to catch the "new scene" event 
  196.     // 
  197.     scriptJob
  198.         -protected
  199.         -parent $panelName
  200.         -event "NewSceneOpened" ("dynPaintNewScenOpenedCB " + $editorName);
  201.  
  202.     // set the script job to catch the "quit" event 
  203.     // 
  204.     scriptJob
  205.         -protected
  206.         -parent $panelName
  207.         -event "quitApplication" ("dynPaintPromptForFileSaving " + $editorName);
  208.  
  209.  
  210.     if (`optionVar -q dynPaint23dToggle` == 2) {
  211.         if ( $gDynPaintEdCreatedFirstTime == 0 ) {
  212.             float $cc[] = `optionVar -q dynPaintPanelClearColour`;
  213.             dynPaintEditor -e -cl $cc[0] $cc[1] $cc[2] $editorName;
  214.         }
  215.     }
  216.  
  217.     $gDynPaintEdCreatedFirstTime = 1;
  218.  
  219.     $dpToolbar = $toolbar;
  220.     dynPaintEditor -e -pa 1 $editorName;
  221. }
  222.     
  223.     
  224.  
  225. global proc dynPaintRemoveCallback(string $panelName) {
  226.  //
  227.  //  Description:
  228.  //             Unparent any editors and save state if required.
  229.  //
  230.         //  Scope the control names to this panel.
  231.         //
  232.         string $control = `scriptedPanel -q -control $panelName`;
  233.         setParent $control;
  234.  
  235. //         $gDynPaintState[0] = `floatSliderGrp -q -v fsg1`;
  236. //         $gDynPaintState[1] = `floatSliderGrp -q -v fsg2`;
  237. //         $gDynPaintState[2] = `floatSliderGrp -q -v fsg3`;
  238. //         $gDynPaintState[3] = `radioButtonGrp -q -sl rbg`;
  239. //         $gDynPaintState[4] = `radioButtonGrp -q -sl rbg2`;
  240. }
  241.  
  242.  
  243. global proc dynPaintDeleteCallback(string $panelName) {
  244.  //
  245.  //  Description:
  246.  //             Delete any editors and do any other cleanup required.
  247.  
  248. }
  249.  
  250. global proc string dynPaintSaveStateCallback(string $panelName) {
  251.  //
  252.  //  Description:
  253.  //             Return a string that will restore the current state
  254.  //             when it is executed.
  255.         $indent = "\n\t\t\t";
  256.  
  257.         return (""
  258. //                         $indent+"$gDynPaintState[0]="+$gDynPaintState[0]+";" +
  259. //                         $indent+"$gDynPaintState[1]="+$gDynPaintState[1]+";" +
  260. //                         $indent+"$gDynPaintState[2]="+$gDynPaintState[2]+";" +
  261. //                         $indent+"$gDynPaintState[3]="+$gDynPaintState[3]+";" +
  262. //                         $indent+"$gDynPaintState[4]="+$gDynPaintState[4]+";" +
  263. //                         $indent+"setDynPaintPanelState $panelName;\n"
  264.         );
  265. }
  266.  
  267. global proc setDynPaintPanelState( string $whichPanel ) {
  268. //
  269. // Create a scripted panel for the DynPaint editor
  270. //
  271. }
  272.